home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / Include / byte.h < prev    next >
C/C++ Source or Header  |  1989-08-17  |  1KB  |  46 lines

  1. /*
  2.  * byte.h --
  3.  *
  4.  *    This file defines a few extra convenience macros for manipulating
  5.  *    byte arrays.
  6.  *
  7.  * Copyright (C) 1986 Regents of the University of California
  8.  * All rights reserved.
  9.  *
  10.  *
  11.  * $Header: /sprite/src/kernel/utils/RCS/byte.h,v 1.4 89/08/15 21:27:19 rab Exp $ SPRITE (Berkeley)
  12.  */
  13.  
  14. #ifndef _BYTE
  15. #define _BYTE
  16.  
  17. /*
  18.  * Byte_FillBuffer is used to copy a value into a buffer and advance
  19.  * the pointer into the buffer by the size of the object copied.
  20.  * Note that pointer must be defined as a character pointer because it is
  21.  * advanced by sizeof(type) characters.
  22.  *
  23.  * Byte_EmptyBuffer assigns into a variable, given a pointer and the type
  24.  * of the variable, then advances the pointer.
  25.  */
  26.  
  27. #define Byte_FillBuffer(pointer, type, value) \
  28.         * ((type *) pointer) = (value) ; \
  29.         pointer += sizeof(type)
  30.  
  31. #define Byte_EmptyBuffer(pointer, type, dest) \
  32.         dest = * ((type *) pointer); \
  33.         pointer += sizeof(type)
  34.  
  35. /*
  36.  * Character arrays (strings & character buffers) are set up to be
  37.  * padded to make sure that objects are aligned on double-word boundaries
  38.  * Byte_AlignAddr rounds lengths to the next boundary.
  39.  */
  40.  
  41. #define Byte_AlignAddr(address) \
  42.     ((((unsigned int) address) + (sizeof(double) - 1)) & \
  43.      ~(sizeof(double) - 1))
  44.  
  45. #endif /* _BYTE */
  46.